<%@ page import="com.unit10.service.EmpService" %>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import ="com.unit10.service.EmpService" %>
<%@ page import="com.unit10.utils.Condition" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.unit10.pojo.Emp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Insert title here</title>
</head>
<body>
<%
    EmpService es=new EmpService();//获取条件参数
    String idCondition=request.getParameter("id");
    String nameCondition=request.getParameter("name");
    String depeNameCondition=request.getParameter("deptName");//构造条件对象
    Condition cd=new Condition(idCondition,nameCondition,depeNameCondition);
    ArrayList<Emp> empsList=es.findEmps(cd);//获取条件查询的结果
    request.setAttribute("empList",empsList);//将获取的数据保存在作用域中
%>
<!-- 头部 -->
<div style="background-color:cornflowerblue; color:white; width:100%;height:80px;">
    <h1 style="line-height:80px;margin-left: 30px;">人力资源管理</h1>
</div>

<!-- 菜单 -->
<table style="border: 1px solid cornflowerblue ; width:100%; ">
    <tr>
        <td width="10%"><a href="http://127.0.0.1:8080/unit10_war_exploded/emp_index.jsp">首页</a></td>
        <td width="10%"><a href="http://127.0.0.1:8080/unit10_war_exploded/emp_addPage.jsp">添加员工</a></td>
        <td width="10%"><a href="http://127.0.0.1:8080/unit10_war_exploded/emp_index.jsp">还是首页</a></td>
        <td></td>
        <td></td>
        <td width="50%"></td>
    </tr>
</table>

<!-- 条件查询 -->
<br /><form action="http://127.0.0.1:8080/unit10_war_exploded/emp_index.jsp" method="get" style="width:100%;">
    条件查询: 员工id <input type="number" style="width: 100px;" name="id"/>
    姓名 <input type="text" style="width: 100px;" name="name"/>
    部门 <select style="width: 160px; height: 25px;" name="deptName">
    <option value="">所有</option>
    <option value="董事会">董事会</option>
    <option value="销售部">销售部</option>
    <option value="研发部">研发部</option>
    <option value="行政部">行政部</option>
    <option value="财务部">财务部</option>
</select>
    <input type="submit" value="查询员工"/>
    <input type="reset" value="清空"/>
</form><br />
<!--数据显示-->
<table border="1px" style="width:100%">
    <tr>
        <td>员工id</td>
        <td>姓名</td>
        <td>年龄</td>
        <td>职位</td>
        <td>入职日期</td>
        <td>薪资</td>
        <td>部门</td>
        <td>修改</td>
        <td>删除</td>
    </tr>
    <c:forEach items="${requestScope.empList}" var="emp">
        <tr>
            <td>${emp.id}</td>
            <td>${emp.name}</td>
            <td>${emp.age}</td>
            <td>${emp.job}</td>
            <td>${emp.hireDate}</td>
            <td>${emp.salary}</td>
            <td>${emp.deptName}</td>
            <td><a href="emp_updatePage.jsp" >修改</a></td>
            <td><a href="emp_del.jsp?id=${emp.id}">删除</a></td>
        </tr>
    </c:forEach>
</table>

</body>
</html>